import React from 'react';
import { connect } from 'react-redux';
import { View, Image } from '@tarojs/components';
import Taro, { useDidShow } from '@tarojs/taro';
import { sourceUrl } from '@/config';
import './index.scss';

const AgreementPage = ({ agreementDetail = {} }) => {
  useDidShow(() => {
    Taro.setNavigationBarTitle({
      title: agreementDetail.name,
    });
  });

  return (
    <View className="agreementPage">
      {agreementDetail?.pics?.length > 0 &&
        agreementDetail.pics.map((url) => (
          <Image
            className="img"
            mode="widthFix"
            src={url.indexOf('http') === 0 ? url : sourceUrl + url}
          ></Image>
        ))}
    </View>
  );
};

export default connect(({ otherApi }) => ({
  agreementDetail: otherApi.agreementDetail,
}))(AgreementPage);
